package com.xuelang.pipeline.artifact.entry.nexus3v1;

import com.xuelang.pipeline.artifact.app.nexus3v1.SecurityUserService;
import com.xuelang.pipeline.artifact.app.nexus3v1.request.CreateUserRequest;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.CreateUserResponse;
import com.xuelang.pipeline.artifact.app.nexus3v1.xo.ApiResponseXO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

/**
 * Nexus3V1 用户管理原生接口web服务
 * 
 * @author xiwen.zxg
 * @since 2024/7/9
 */
@RestController
@RequestMapping("/security/user")
public class SecurityUserController {
    
    @Autowired
    SecurityUserService securityUserService;

    /**
     * 新增用户
     *
     * @param createUserRequest
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResponseXO<CreateUserResponse> createRole(@RequestBody @Valid CreateUserRequest createUserRequest) {
        return securityUserService.createUser(createUserRequest);
    }

    /**
     * 删除用户
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResponseXO<Void> deleteRole(@PathVariable("id") String id) {
        return securityUserService.deleteUser(id);
    }
    
}
